<?php 
class product_models_show extends CI_Model{
   
    public function get_id_from_link($link){
    	$this->load->database();
    	$get= $this->db->get_where('product',array('prd_active'=>1,'prd_link'=>$link),1);
    	if($get->num_rows()){
    		$row= $get->result();
    		return $row[0]->prd_id;
    	}
    	return false;
    }

    public function active_id_from_link($link){
    	$this->load->database();
    	$get= $this->db->get_where('product',array('prd_link'=>$link),1);
    	if($get->num_rows()){
    		$this->db->update('product', array('prd_active'=>1),array('prd_link'=>$link));
    		$row= $get->result();
    		return $row[0]->prd_id;
    	}
    	return false;
    }
	 public function counter($id){
	    	$this->load->database();
	    	$get= $this->db->get_where('product',array('prd_active'=>1,'prd_id'=>$id),1);
	    	if($get->num_rows()){
	    		$row= $get->result();
	    		$this->db->update('product', array('prd_counter'=> $row[0]->prd_counter+1),array('prd_id'=>$id));
	    		
	    		return $row[0]->prd_counter;
	    	}
	    	return false;
	    }
    
}